<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require 'dbcon.php';
$username=$_REQUEST['username'];
$sex=$_REQUEST['sex'];
$imgurl=$_REQUEST['imgurl'];
$message=$_REQUEST['message'];
date_default_timezone_set('Asia/Shanghai');
$mdate=date("Y-m-d h:i:s");
$sql="INSERT INTO t_message(username, sex, message, imgurl,m_date) VALUES( '{$username}', '{$sex}', '{$message}', '{$imgurl}', '{$mdate}')";
$rs=$db->query($sql);//执行查询语句$sql，生成结果集$result
$db->close();//关闭数据库连接
if ($rs==true)
{
    echo "<script type='text/javascript'>";    
    echo "window.location.href='index.php'";
    echo "</script>";
}
else   
{
    echo "<script type='text/javascript'>";  
    echo "alert('留言失败！');";
    echo "window.location.href='index.php'";
    echo "</script>";
}



